import request from '@/utils/request'


export function selectById_good(requisitionId) {
  return request({
    url: '/TakeMaterial/material-requisition/selectById',
    method: 'get',
    params: {
      requisitionId: requisitionId
    }
  })
}
export function selectAll() {
  return request({
    url: '/TakeMaterial/material-requisition/selectAll',
    method: 'get'
  })
}

export function selectByReId(requisitionId) {
  return request({
    url: '/TakeMaterial/requisition-header/selectByReId',
    method: 'get',
    params: {
      requisitionId: requisitionId
    }
  })
}





export function Select_AccId(acceptID) {
  return request({
    url: '/TakeMaterial/material-requisition/Select_AccId',
    method: 'get',
    params: {
      acceptID: acceptID
    }
  })
}

export function editGood(id, requisition_id, name, specification, unit, dueNum, actualNum, price, tax, remark) {
  return request({
    url: 'TakeMaterial/material-requisition/editGood',
    method: 'post',
    data: {
      id: id,
      requisitionId: requisition_id,
      name: name,
      specification: specification,
      unit: unit,
      dueNum: dueNum,
      actualNum: actualNum,
      price: price,
      tax: tax,
      remark: remark
    }
  })
}
// 删除物料信息
export function RemoveGood(id) {
  return request({
    url: '/TakeMaterial/material-requisition/RemoveGood',
    method: 'post',
    params: {
      id: id
    }
  })
}





//  插入新的物料申请计划
export function insertPurchase(materialName, purchaseNum, specification, unit, requisitionId, remark, price) {
  return request({
    url: '/TakeMaterial/material-requisition/insertGoods',
    method: 'post',
    data: {
      materialName: materialName,
      purchaseNum: purchaseNum,
      specification: specification,
      unit: unit,
      remark: remark,
      requisitionId: requisitionId,
      price: price
    }
  })
}

//  根据id对申请物料信息进行修改
export function updateMaterial(id, purchaseNum, partUsed, remark) {
  return request({
    url: '/materialPurchase/material-purchase/updMaterial',
    method: 'post',
    params: {
      id: id,
      purchaseNum: purchaseNum,
      partUsed: partUsed,
      remark: remark
    }
  })
}


//  根据id删除申请信息
export function deleteById(id) {
  return request({
    url: '/materialPurchase/material-purchase/delById',
    method: 'get',
    params: {
      id: id
    }
  })
}

//  查询所有物料信息
export function selAllMaterial(curPage, pageSize) {
  return request({
    url: '/materialPurchase/material-purchase/selPageMateriInfo',
    method: 'post',
    params: {
      currentPage: curPage,
      pageSize: pageSize
    }
  })
}

//  根据关键字 查询物料信息
export function selMaterialByName(name) {
  return request({
    url: '/entryWarehouse/base-information/search',
    method: 'get',
    params: {
      search: name
    }
  })
}

//  查询截止日期
export function selDeadLine() {
  return request({
    url: '/materialPurchase/plan-deadline/selPlanDate',
    method: 'get'
  })
}

// 查询用户所属部门信息
export function selAccountDepart(name) {
  return request({
    url: '/materialPurchase/material-purchase/selAccount',
    method: 'post',
    params: {
      account: name
    }
  })
}
